package cn.byapps.chensheng.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import cn.byapps.chensheng.entity.WxMaterialNewsArticle;

/**
 * @author iva0512@gmail.com
 */
public interface WxMaterialNewsArticleDao {
    @Results(id = "item",value={
        @Result(property = "mediaId", column = "media_id",id = true),
        @Result(property = "author", column = "author"),
        @Result(property = "title", column = "title"),
        @Result(property = "thumbMediaId", column = "thumb_media_id"),
        @Result(property = "thumbUrl", column = "thumb_url"),
        @Result(property = "contentSourceUrl", column = "content_source_url"),
        @Result(property = "digest", column = "digest"),
        @Result(property = "needOpenComment", column = "need_open_comment"),
        @Result(property = "onlyFansCanComment", column = "only_fans_can_comment"),
        @Result(property = "showCoverPic", column = "show_cover_pic"),
        @Result(property = "url", column = "url")
     }
    ) 
    @Select("select * from wx_material_news_article")
    List<WxMaterialNewsArticle> findAll();

    @ResultMap("item")
    @Select("select * from wx_material_news_article")
    List<WxMaterialNewsArticle> findByPage(@Param("pageNum") Integer pageNum,@Param("pageSize") Integer pageSize);
    
    @ResultMap("item")
    @Select("select * from wx_material_news_article where media_id = #{mediaId}")
    WxMaterialNewsArticle getById(String mediaId);
}